﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mmoss.application.classes;

namespace mmoss.application
{
    public partial class frmCardSwipe : Form
    {

        public frmCardSwipe()
        {
            this.Load += new EventHandler(frmCardSwipe_Load);
            //txtCCSwipe.KeyDown += new KeystrokeMessageFilter.KeyDelegate(KeystrokeMessageFilter.keyItemDown);
            InitializeComponent();
        }


        void frmCardSwipe_Load(object sender, EventArgs e)
        {
            ((frmContainer)this.MdiParent).keyStrokeMessageFilter.CCScanned += new KeystrokeMessageFilter.CCScannedGood(keyStrokeMessageFilter_CCScanned);
            ((frmContainer)this.MdiParent).keyStrokeMessageFilter.CardCharRead += new KeystrokeMessageFilter.CharacterRead(keyStrokeMessageFilter_CardCharRead);
            //cardScan l_processing = new cardScan();
            //this.KeyDown += new KeyEventHandler(cardScan.ccKeyPress);
        }

        void keyStrokeMessageFilter_CardCharRead(string s_buffer)
        {
            lblSwipe.Text = (s_buffer.Length>21?s_buffer.Substring(s_buffer.Length-21,21):s_buffer);
        }

        void keyStrokeMessageFilter_CCScanned(mmoss.classes.CCCard l_Card)
        {
            MessageBox.Show("card read with card num = " + l_Card.CardNumber);
        }

        void frmCardSwipe_KeyDown(object sender, KeyEventArgs e)
        {
            lblSwipe.Text = lblSwipe.Text + (char)e.KeyValue;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
